package com.zdp.test.proxy.jdkproxy;

import java.lang.reflect.Proxy;

/**
 * @describte:Jdk代理类工厂
 * @program:ThoughtTest
 * @author:zhengdp
 * @create:2021-12-25 20:57:30
 **/
public class JdkProxyFactory {

    public static <T> T getProxyObject(T target){
        JdkProxyInvocation jdkProxyInvocation = new JdkProxyInvocation(target);

        // 通过Proxy来生成代理类
        return (T)Proxy.newProxyInstance(target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),jdkProxyInvocation);
    }

}
